//
//  WYChannelLabel.m
//  网易新闻19
//
//  Created by heima on 16/8/13.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "WYChannelLabel.h"
#import "WYChannelModel.h"

#define kLabelBigSize 18
#define kLabelNormalSize 18

@implementation WYChannelLabel

- (void)setScale:(CGFloat)scale {
  _scale = scale;
  // 2. 设置对应label的缩放比例
  [self setTextColor:[UIColor colorWithRed:0 green:0 blue:scale alpha:1]];

  // 3. 变大变小
  // 14 --> 0
  // 18 --> 1
  // 假如说: 传入的scale是0.5
  // sc --> 16
  // 16 / 14 == 1.xxx
//  CGFloat sc = 14 + (18 - 14) * scale;
//  self.transform = CGAffineTransformMakeScale(sc / 14, sc / 14);
}

+ (instancetype)labelWithModel:(WYChannelModel *)model {

  WYChannelLabel *label = [self labelWithText:model.tname andTextColor:[UIColor blackColor] andFontSize:kLabelBigSize];
    
  // 根据内容调整大小
  [label sizeToFit];
    
  // 计算字号为18的大小这这后,再把字体改成14,原因是防止在放大的时候空间不足
  label.font = [UIFont systemFontOfSize:kLabelNormalSize];

  return label;
}

@end
